This tutorial will teach you the basics of using RooFit. You are driving the examples from a notebook, but all the hard work happens in .C macros. This means you can benefit from the useful features of a notebook (mixing equations, text, images and code) while keeping your code in a form that is easy to edit in an editor and written in your favourite language.
Think of the notebook as an executable README file for your project.
To start with we have to generate some data for use during the tutorial:
In [1]:
%%bash
root.exe -b -l -q roofit_tutorial_generate_data.C > /dev/null
Note: by starting a cell with %%bash you tell the notebook that the commands are to be executed in a shell.
Note: You can make quick edits of roofit_tutorial_generate_data.C directly from your browser or open a terminal and edit in vim or emacs.
Besides printing a lot of text it also created a dataset for us in:
In [2]:
!ls *.root
Note: An exclamation mark means: "single line shell command".
The first few bits of code in this tutorial will load the dataset from the
ntuple and plot them in the manner of RooFit. This is to get you started.
The first_plots.C script will load the data and make some basic plots to check everything is fine. We will display the images directly in the notebook here.
In [3]:
%%bash
root.exe -b -l -q first_plots.C > /dev/null
In [4]:
from IPython.display import Image
Image(filename='dataplot.png')
Out[4]:
This is just the beginning of a short RooFit tutorial. You can find the complete version here: cofitzpa/roofit_tutorial_solutions.